package menu;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;
import java.net.URL;
import javax.imageio.ImageIO;
import javax.swing.JPanel;

public class PanelCredits extends JPanel implements MouseListener,ActionListener{
	private static final long serialVersionUID = 30520100019L;
	private BufferedImage bkground = LoadImg("textures/credits.png");
	public PanelCredits(PanelMain panelMain)
	{
		super(true);
		this.setOpaque(true);
		this.setLayout(new BorderLayout());
		this.setPreferredSize(new Dimension(640,400));
		this.setBorder(null);
		this.addMouseListener(this);
		repaint();
		System.out.println("PANEL CREDITS");
	}
	
	private BufferedImage LoadImg(String path)
	{
		BufferedImage img;
		URL url = MainGameScreen.class.getClassLoader().getResource(path);
	    try
	    {
	    	System.out.println("FILE: " + url.getPath());
	    	img=ImageIO.read(url);
	    } 
	    catch(Exception e)
	    {
	    	System.out.println("Errore!!!");
	    	img=null;
	    }
	    return img;
	}
	
	@SuppressWarnings("static-access")
	@Override
	protected void paintComponent(Graphics g) {
		super.paintComponent(g);
		g.drawImage(bkground,0,0,this.WIDTH,this.HEIGHT,null);
		System.out.println("IMAGE CREDITS");
	}

	@Override
	public void mouseClicked(MouseEvent arg0) {
		this.setVisible(false);
		
	}

	@Override
	public void mouseEntered(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseExited(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	
}
